package com.wc.alorithm_luogu._BFS.奇怪的电梯;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2025/1/10 20:22
 * @description
 * https://www.luogu.com.cn/problem/P1135
 */
public class Main {
    /**
     * 思路：
     * 典型的BFS求最短路
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 210, INF = 0x3f3f3f3f;
    static int[] f = new int[N], a = new int[N];
    static int[] q = new int[N];
    static int n, st, ed;

    public static void main(String[] args) {
        n = sc.nextInt();
        st = sc.nextInt();
        ed = sc.nextInt();
        Arrays.fill(f, 1, n + 1, INF);
        for (int i = 1; i <= n; i++) a[i] = sc.nextInt();
        int hh = 1, tt = 1;
        q[1] = st;
        f[st] = 0;
        while (hh <= tt) {
            int t = q[hh++];
            int up = t + a[t];
            if (up <= n && f[up] > f[t] + 1) {
                f[up] = f[t] + 1;
                q[++tt] = up;
            }
            int down = t - a[t];
            if (down >= 1 && f[down] > f[t] + 1) {
                f[down] = f[t] + 1;
                q[++tt] = down;
            }
        }
        out.println(f[ed] == INF ? -1 : f[ed]);
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}

